Stil Metin Ekle
IronWord'da 'Stil Metni Ekle' özelliği, geliştiricilerin bir DOCX belgesi eklerken çeşitli metin stil seçenekleri uygulamasına olanak tanır. Font ailesini, boyutunu, rengini ve kalın, italik, alt çizgi ve üstü çizili gibi stil niteliklerini belirlemek gibi metnin görünümü üzerinde ayrıntılı kontrol sağlar. Bir dokümanın içindeki bireysel metin öğelerinin sunumunu geliştiricilerin özelleştirilmiş bir görünüm ve his sağlayarak kişiselleştirebilmeleri için TextContent içeren Run bir nesne oluşturup Run üzerine TextStyle atayarak gerçekleştirilir.
Bu özellik, belirli bölümlerin farklı stiller gerektirdiği raporlar veya mektuplar gibi profesyonelce formatlanmış belgelerin dinamik olarak oluşturulması için faydalıdır. TextStyle sınıfı, bu özelliklerin kolaylıkla işlenmesini sağlar ve aynı doküman içinde hem basit hem de karmaşık stillendirme yapılmasına olanak tanır.
Temel Noktalar
-
Stilli Run Oluşturma:
- A
Runobject is created containingTextContentwith the desired text. - The
Styleproperty of theRunis assigned aTextStyleobject to apply formatting.
- A
-
TextStyle'i Ayarlama:
FontSize: Set at theTextStylelevel (not insideFont) to specify text size.TextFont: Contains font properties includingFontFamilyfor font selection.Color: Specifies the text color usingIronWord.Models.Color.IsBoldandIsItalic: Boolean properties for bold and italic formatting.Underline: Adds underline styling to the text.Strike: Applies strikethrough formatting usingStrikeValueenum.
- Belgeye Ekleme:
- Use
AddChildto add the styledRunto aParagraph. - The paragraph is then added to the document with
AddParagraph.
- Use
Kod Açıklaması
Bu kod, IronWord kullanilarak bir DOCX dosyasi icinde metin oluşturma ve stil uygulama işlemlerini göstermektedir. It begins by initializing a new WordDocument object, representing the document to be generated. A Run object is created containing TextContent with the string "Styled text example" and a TextStyle is applied to the Run to configure the appearance of the text.
The TextStyle includes settings for font size set at the TextStyle level (not inside Font), font family configured via TextFont, text color, and bold formatting. Bu ayarlar, metnin son dokümanda nasıl gorunecegini ozellestirir.
After the Run is styled, the AddChild method adds the Run object to a paragraph in the document. Bu metod, stilize icerigi uygun formatta bir Word belgesine yerlestirir. Finally, the SaveAs method is called to export the document as "styled_document.docx". Sonuc, cikan dosyada tüm font ve formatlama özelliklerini koruyarak eklenen metnin belirtilen stillere gore formatlandigi bir Word belgesidir.
Daha Fazla Stil Ipuclari icin Doküman Elemanlari Eğitimlerini Kesfedin

